//
//  ProfileImageProcesser.h
//  TuiTe
//
//  Created by 张 霄鹤 on 10-3-26.
//  Copyright 2010 xhzhang. All rights reserved.
//

#import <Foundation/Foundation.h>

@protocol ProfileImageProcesserDelegate;

@interface ProfileImageProcesser : NSObject {
	NSMutableDictionary *imageCache;
	id<ProfileImageProcesserDelegate> _delegate;
	/**
	 * 下载图像队列
	 * 内部保存着请求的图像地址，必须确保唯一
	 */
	NSMutableArray *queue;
	/**
	 * 当前线程是否正在加载
	 */
	BOOL loading;
	
	UIImage *deflogo;
}

@property(nonatomic, retain) id<ProfileImageProcesserDelegate> delegate;

@property(nonatomic, retain) UIImage *deflogo;

+ (ProfileImageProcesser *)getInstance;

/**
 * 将图像添加到缓存中
 * @param url NSString 图像网址
 * @param img UIImage 图像实例
 */
- (void)putImage:(NSString *)url withImage:(UIImage *)img;

/**
 * 从缓存中获取图像
 * @param url NSString 图像网址
 * @return UIImage 图像实例
 */
- (UIImage *)getImage:(NSString *)url;

/**
 * 检查是否包含相应的图像
 *
 */
- (BOOL)haveImage:(NSString *)url;

/**
 * 删除图像
 */
- (void)removeImage:(NSString *)url;

/**
 * 请求加载图像
 * @param url 图像网址
 */
- (void)loadImage:(NSString *)url;

/**
 * 实际的加载线程
 */
- (void)loadThreadImpl;

- (void)loadImagesFromData;

- (void)saveImagesToData;

@end

@protocol ProfileImageProcesserDelegate

- (void)imageDidLoadFinished:(NSString *)imgURL;

@end



